#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
typedef long long ll;
const int MAXN=3e5+7;
struct node {
	ll st,en;
	ll point;
	bool operator< (const node& a) const {
		return en < a.en;
	}
};
node a[MAXN];
ll en[MAXN];
ll dp[MAXN]; 
int main() {
	int n;
//	freopen("in.txt", "r", stdin);
	cin.sync_with_stdio(false);
	while (cin>>n) {
		a[0].st=0; a[0].en=0; a[0].point=0; en[0]=0;
		for (int i=1; i<=n; ++i) {
			cin>>a[i].st>>a[i].point>>a[i].en;
			a[i].en=a[i].st+a[i].en;
			en[i]=a[i].en;
		}
		dp[0]=0;
		sort(a+1, a+n+1); sort(en+1, en+n+1);
//		for (int i=0; i<=n; ++i) cout<<en[i]<<' '<<a[i].point<<endl;
//		cout<<endl;
		ll res=0;
		for (int i=1; i<=n; ++i) {
			ll fi=a[i].st;
			ll p=upper_bound(en, en+i, fi)-en-1;
//			cout<<"p: "<<p<<"--->";
			dp[i]=max(a[i].point+dp[p], dp[i-1]);
//			cout<<dp[i]<<endl;
			if (dp[i]>res) res=dp[i];
		}
		cout<<res<<endl;
	}
	return 0;
} 
